import { listFactory } from "@/api/SYSConfig/factory"
import { listFactoryArea } from "@/api/SYSConfig/factoryArea"
import { listProductionType } from "@/api/SYSConfig/productionType"
import { listMachineType } from "@/api/SYSConfig/machineType"

// 车间
export const factoryIdOptions = ref([])
listFactory().then(res => {
  res.rows.forEach((item) => {
    if(factoryIdOptions.value.indexOf(item.factoryId) === -1){
      factoryIdOptions.value.push({
        label: item.factoryId,
        value: item.factoryId
      })
    }
  })
})

// 车间区域
export const factoryAreaIdOptions = ref([])
listFactoryArea({
  pageNum: 1,
  pageSize: 999999
}).then(res => {
  res.rows.forEach((item) => {
    if(factoryAreaIdOptions.value.indexOf(item.factoryAreaId) === -1){
      factoryAreaIdOptions.value.push({
        label: item.factoryAreaId,
        value: item.factoryAreaId
      })
    }
  })
})

// 制造类型
export const listProductionTypeOptions = ref([])
listProductionType({
  pageNum: 1,
  pageSize: 999999
}).then(res => {
  res.rows.forEach((item) => {
    if(listProductionTypeOptions.value.indexOf(item.productionTypeId) === -1){
      listProductionTypeOptions.value.push({
        label: item.productionTypeId,
        value: item.productionTypeId
      })
    }
  })
})

// 设备类型
export const listMachineTypeOptions = ref([])
listMachineType({
  pageNum: 1,
  pageSize: 999999
}).then(res => {
  res.rows.forEach((item) => {
    if(listMachineTypeOptions.value.indexOf(item.machineTypeId) === -1){
      listMachineTypeOptions.value.push({
        label: item.machineTypeId,
        value: item.machineTypeId
      })
    }
  })
})